/**
 * <copyright>
 *
 * Copyright (c) 2011 Zeligsoft (2009) Limited
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: 
 *   Zeligsoft (2009) Limited - Initial API and implementation
 *
 * </copyright>
 *
 */
package org.omg.deployment.impl;

import java.util.Collection;

import javax.xml.namespace.QName;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.BasicFeatureMap;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;

import org.omg.deployment.DataType;
import org.omg.deployment.DeploymentPackage;
import org.omg.deployment.ValueMemberType;
import org.omg.deployment.ValueType;

import org.omg.xmi.Extension;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Value Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getGroup <em>Group</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getTypeId <em>Type Id</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getModifier <em>Modifier</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getBaseType <em>Base Type</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getMember <em>Member</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getExtension <em>Extension</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getHref <em>Href</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getId <em>Id</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getIdref <em>Idref</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getLabel <em>Label</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getType <em>Type</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getUuid <em>Uuid</em>}</li>
 *   <li>{@link org.omg.deployment.impl.ValueTypeImpl#getVersion <em>Version</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ValueTypeImpl extends EObjectImpl implements ValueType {
	/**
	 * The cached value of the '{@link #getGroup() <em>Group</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGroup()
	 * @generated
	 * @ordered
	 */
	protected FeatureMap group;

	/**
	 * The default value of the '{@link #getHref() <em>Href</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHref()
	 * @generated
	 * @ordered
	 */
	protected static final String HREF_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getHref() <em>Href</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHref()
	 * @generated
	 * @ordered
	 */
	protected String href = HREF_EDEFAULT;

	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected String id = ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getIdref() <em>Idref</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIdref()
	 * @generated
	 * @ordered
	 */
	protected static final String IDREF_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getIdref() <em>Idref</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIdref()
	 * @generated
	 * @ordered
	 */
	protected String idref = IDREF_EDEFAULT;

	/**
	 * The default value of the '{@link #getLabel() <em>Label</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLabel()
	 * @generated
	 * @ordered
	 */
	protected static final String LABEL_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getLabel() <em>Label</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLabel()
	 * @generated
	 * @ordered
	 */
	protected String label = LABEL_EDEFAULT;

	/**
	 * The default value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected static final QName TYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected QName type = TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getUuid() <em>Uuid</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUuid()
	 * @generated
	 * @ordered
	 */
	protected static final String UUID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getUuid() <em>Uuid</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUuid()
	 * @generated
	 * @ordered
	 */
	protected String uuid = UUID_EDEFAULT;

	/**
	 * The default value of the '{@link #getVersion() <em>Version</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getVersion()
	 * @generated
	 * @ordered
	 */
	protected static final String VERSION_EDEFAULT = "2.1";

	/**
	 * The cached value of the '{@link #getVersion() <em>Version</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getVersion()
	 * @generated
	 * @ordered
	 */
	protected String version = VERSION_EDEFAULT;

	/**
	 * This is true if the Version attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean versionESet;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ValueTypeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DeploymentPackage.eINSTANCE.getValueType();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureMap getGroup() {
		if (group == null) {
			group = new BasicFeatureMap(this,
					DeploymentPackage.VALUE_TYPE__GROUP);
		}
		return group;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<String> getName() {
		return getGroup().list(DeploymentPackage.eINSTANCE.getValueType_Name());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<String> getTypeId() {
		return getGroup().list(
				DeploymentPackage.eINSTANCE.getValueType_TypeId());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<String> getModifier() {
		return getGroup().list(
				DeploymentPackage.eINSTANCE.getValueType_Modifier());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<DataType> getBaseType() {
		return getGroup().list(
				DeploymentPackage.eINSTANCE.getValueType_BaseType());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ValueMemberType> getMember() {
		return getGroup().list(
				DeploymentPackage.eINSTANCE.getValueType_Member());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Extension> getExtension() {
		return getGroup().list(
				DeploymentPackage.eINSTANCE.getValueType_Extension());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getHref() {
		return href;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setHref(String newHref) {
		String oldHref = href;
		href = newHref;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					DeploymentPackage.VALUE_TYPE__HREF, oldHref, href));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(String newId) {
		String oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					DeploymentPackage.VALUE_TYPE__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getIdref() {
		return idref;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIdref(String newIdref) {
		String oldIdref = idref;
		idref = newIdref;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					DeploymentPackage.VALUE_TYPE__IDREF, oldIdref, idref));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getLabel() {
		return label;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLabel(String newLabel) {
		String oldLabel = label;
		label = newLabel;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					DeploymentPackage.VALUE_TYPE__LABEL, oldLabel, label));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public QName getType() {
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(QName newType) {
		QName oldType = type;
		type = newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					DeploymentPackage.VALUE_TYPE__TYPE, oldType, type));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getUuid() {
		return uuid;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUuid(String newUuid) {
		String oldUuid = uuid;
		uuid = newUuid;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					DeploymentPackage.VALUE_TYPE__UUID, oldUuid, uuid));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getVersion() {
		return version;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setVersion(String newVersion) {
		String oldVersion = version;
		version = newVersion;
		boolean oldVersionESet = versionESet;
		versionESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					DeploymentPackage.VALUE_TYPE__VERSION, oldVersion, version,
					!oldVersionESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetVersion() {
		String oldVersion = version;
		boolean oldVersionESet = versionESet;
		version = VERSION_EDEFAULT;
		versionESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET,
					DeploymentPackage.VALUE_TYPE__VERSION, oldVersion,
					VERSION_EDEFAULT, oldVersionESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetVersion() {
		return versionESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case DeploymentPackage.VALUE_TYPE__GROUP:
			return ((InternalEList<?>) getGroup()).basicRemove(otherEnd, msgs);
		case DeploymentPackage.VALUE_TYPE__BASE_TYPE:
			return ((InternalEList<?>) getBaseType()).basicRemove(otherEnd,
					msgs);
		case DeploymentPackage.VALUE_TYPE__MEMBER:
			return ((InternalEList<?>) getMember()).basicRemove(otherEnd, msgs);
		case DeploymentPackage.VALUE_TYPE__EXTENSION:
			return ((InternalEList<?>) getExtension()).basicRemove(otherEnd,
					msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case DeploymentPackage.VALUE_TYPE__GROUP:
			if (coreType)
				return getGroup();
			return ((FeatureMap.Internal) getGroup()).getWrapper();
		case DeploymentPackage.VALUE_TYPE__NAME:
			return getName();
		case DeploymentPackage.VALUE_TYPE__TYPE_ID:
			return getTypeId();
		case DeploymentPackage.VALUE_TYPE__MODIFIER:
			return getModifier();
		case DeploymentPackage.VALUE_TYPE__BASE_TYPE:
			return getBaseType();
		case DeploymentPackage.VALUE_TYPE__MEMBER:
			return getMember();
		case DeploymentPackage.VALUE_TYPE__EXTENSION:
			return getExtension();
		case DeploymentPackage.VALUE_TYPE__HREF:
			return getHref();
		case DeploymentPackage.VALUE_TYPE__ID:
			return getId();
		case DeploymentPackage.VALUE_TYPE__IDREF:
			return getIdref();
		case DeploymentPackage.VALUE_TYPE__LABEL:
			return getLabel();
		case DeploymentPackage.VALUE_TYPE__TYPE:
			return getType();
		case DeploymentPackage.VALUE_TYPE__UUID:
			return getUuid();
		case DeploymentPackage.VALUE_TYPE__VERSION:
			return getVersion();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case DeploymentPackage.VALUE_TYPE__GROUP:
			((FeatureMap.Internal) getGroup()).set(newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__NAME:
			getName().clear();
			getName().addAll((Collection<? extends String>) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__TYPE_ID:
			getTypeId().clear();
			getTypeId().addAll((Collection<? extends String>) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__MODIFIER:
			getModifier().clear();
			getModifier().addAll((Collection<? extends String>) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__BASE_TYPE:
			getBaseType().clear();
			getBaseType().addAll((Collection<? extends DataType>) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__MEMBER:
			getMember().clear();
			getMember()
					.addAll((Collection<? extends ValueMemberType>) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__EXTENSION:
			getExtension().clear();
			getExtension().addAll((Collection<? extends Extension>) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__HREF:
			setHref((String) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__ID:
			setId((String) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__IDREF:
			setIdref((String) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__LABEL:
			setLabel((String) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__TYPE:
			setType((QName) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__UUID:
			setUuid((String) newValue);
			return;
		case DeploymentPackage.VALUE_TYPE__VERSION:
			setVersion((String) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case DeploymentPackage.VALUE_TYPE__GROUP:
			getGroup().clear();
			return;
		case DeploymentPackage.VALUE_TYPE__NAME:
			getName().clear();
			return;
		case DeploymentPackage.VALUE_TYPE__TYPE_ID:
			getTypeId().clear();
			return;
		case DeploymentPackage.VALUE_TYPE__MODIFIER:
			getModifier().clear();
			return;
		case DeploymentPackage.VALUE_TYPE__BASE_TYPE:
			getBaseType().clear();
			return;
		case DeploymentPackage.VALUE_TYPE__MEMBER:
			getMember().clear();
			return;
		case DeploymentPackage.VALUE_TYPE__EXTENSION:
			getExtension().clear();
			return;
		case DeploymentPackage.VALUE_TYPE__HREF:
			setHref(HREF_EDEFAULT);
			return;
		case DeploymentPackage.VALUE_TYPE__ID:
			setId(ID_EDEFAULT);
			return;
		case DeploymentPackage.VALUE_TYPE__IDREF:
			setIdref(IDREF_EDEFAULT);
			return;
		case DeploymentPackage.VALUE_TYPE__LABEL:
			setLabel(LABEL_EDEFAULT);
			return;
		case DeploymentPackage.VALUE_TYPE__TYPE:
			setType(TYPE_EDEFAULT);
			return;
		case DeploymentPackage.VALUE_TYPE__UUID:
			setUuid(UUID_EDEFAULT);
			return;
		case DeploymentPackage.VALUE_TYPE__VERSION:
			unsetVersion();
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case DeploymentPackage.VALUE_TYPE__GROUP:
			return group != null && !group.isEmpty();
		case DeploymentPackage.VALUE_TYPE__NAME:
			return !getName().isEmpty();
		case DeploymentPackage.VALUE_TYPE__TYPE_ID:
			return !getTypeId().isEmpty();
		case DeploymentPackage.VALUE_TYPE__MODIFIER:
			return !getModifier().isEmpty();
		case DeploymentPackage.VALUE_TYPE__BASE_TYPE:
			return !getBaseType().isEmpty();
		case DeploymentPackage.VALUE_TYPE__MEMBER:
			return !getMember().isEmpty();
		case DeploymentPackage.VALUE_TYPE__EXTENSION:
			return !getExtension().isEmpty();
		case DeploymentPackage.VALUE_TYPE__HREF:
			return HREF_EDEFAULT == null ? href != null : !HREF_EDEFAULT
					.equals(href);
		case DeploymentPackage.VALUE_TYPE__ID:
			return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
		case DeploymentPackage.VALUE_TYPE__IDREF:
			return IDREF_EDEFAULT == null ? idref != null : !IDREF_EDEFAULT
					.equals(idref);
		case DeploymentPackage.VALUE_TYPE__LABEL:
			return LABEL_EDEFAULT == null ? label != null : !LABEL_EDEFAULT
					.equals(label);
		case DeploymentPackage.VALUE_TYPE__TYPE:
			return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT
					.equals(type);
		case DeploymentPackage.VALUE_TYPE__UUID:
			return UUID_EDEFAULT == null ? uuid != null : !UUID_EDEFAULT
					.equals(uuid);
		case DeploymentPackage.VALUE_TYPE__VERSION:
			return isSetVersion();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy())
			return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (group: ");
		result.append(group);
		result.append(", href: ");
		result.append(href);
		result.append(", id: ");
		result.append(id);
		result.append(", idref: ");
		result.append(idref);
		result.append(", label: ");
		result.append(label);
		result.append(", type: ");
		result.append(type);
		result.append(", uuid: ");
		result.append(uuid);
		result.append(", version: ");
		if (versionESet)
			result.append(version);
		else
			result.append("<unset>");
		result.append(')');
		return result.toString();
	}

} //ValueTypeImpl
